package com.it.bigdata.util;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

public class HttpUtil {
    /**
     * 下载页面的工具类
     * @param url
     * @return
     */
    public static String simpleDownLoad(String url) {
        HttpClient httpClient = HttpClients.createDefault();
        HttpGet httpGet = new HttpGet(url);
        try {
            HttpResponse response = httpClient.execute(httpGet);
            String html = EntityUtils.toString(response.getEntity());
            return html;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
